package com.freemalll.merchant.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freemalll.common.core.annotation.ResultInterceptor;
import com.freemalll.merchant.domain.dto.*;
import com.freemalll.merchant.domain.vo.*;
import com.freemalll.merchant.service.merchantAuditManage.MerchantAuditManageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author songshixiong
 * @ClassName MerchantAuditManageController
 * @description:
 * @date 2025年05月28日
 * @version: 1.0
 */
@Tag(name = "审核管理：审核中心")
@RestController
@RequestMapping("/audit-manage")
@ResultInterceptor
@AllArgsConstructor
@Validated
public class MerchantAuditManageController {

    private final MerchantAuditManageService merchantAuditManageService;

    @PostMapping("/listPage")
    @Operation(summary = "首页列表详情分页")
    public Page<MerchantAuditPageVo> listPage(@RequestBody MerchantAuditManageDto dto) {
        return merchantAuditManageService.listPage(dto);
    }

    @PostMapping("/countByAuthStatus")
    @Operation(summary = "各审核状态总数量统计")
    public MerchantApplyCountVo countByAuthStatus(@RequestBody MerchantAuditManageDto dto) {
        return merchantAuditManageService.countByAuthStatus(dto);
    }

    @PostMapping("/auditEditPage")
    @Operation(summary = "记录日志分页")
    public List<MerchantAuditEditPageVo> auditEditPage(@RequestBody MerMerchantAuditEditLogDto dto) {
        return merchantAuditManageService.auditEditPage(dto);
    }

    @PostMapping("/flowPage")
    @Operation(summary = "审批流程记录分页")
    public List<MerAuthFlowLogPageVo> flowPage(@RequestBody MerAuthFlowLogDto dto) {
        return merchantAuditManageService.flowPage(dto);
    }

    @GetMapping("/getMerInfoById")
    @Operation(summary = "获取商户详情")
    public MerchantAuditVo getMerInfoById(@RequestParam(value = "merId") String merId, @RequestParam(value = "listType") String listType) {
        return merchantAuditManageService.getMerInfoById(merId, listType);
    }


    @GetMapping("/getAttachInfoList")
    @Operation(summary = "合作申请页面，如果是补件页面，获取需要补件的附件以及详情")
    public HistoryDeletedListVO getSupplementAttachInfoList(@RequestParam(value = "merId") String merId) {
        return merchantAuditManageService.getSupplementAttachInfoList(merId);
    }

    @PostMapping("/editMerAttach")
    @Operation(summary = "附件照片下结论")
    public void editMerAttach(@RequestBody MerAttachDto vo) {
        merchantAuditManageService.editMerchantInfo(vo);
    }

    @PostMapping("/editMerchantInfo")
    @Operation(summary = "编辑商户详情")
    public void editMerchantInfo(@RequestBody MerchantAuditDetailVo vo) {
        merchantAuditManageService.editMerchantInfo(vo);
    }

    @PostMapping("/editCapitalOrder")
    @Operation(summary = "编辑资方顺位")
    public void editCapitalOrder(@RequestBody List<MerMerchantCapitalOrderDto> vo) {
        merchantAuditManageService.editCapitalOrder(vo);
    }

    @PostMapping("/editBusinessLicense")
    @Operation(summary = "编辑证照信息")
    public void editBusinessLicense(@RequestBody @Valid BusinessLicenseDto dto) {
        merchantAuditManageService.editBusinessLicense(dto);
    }

    @PostMapping("/editCorporateInfo")
    @Operation(summary = "编辑法人信息")
    public void editCorporateInfo(@RequestBody @Valid CorporateInfoDto dto) {
        merchantAuditManageService.editCorporateInfo(dto);
    }

    @PostMapping("/editMedicalLicense")
    @Operation(summary = "编辑执业许可证大健康")
    public void editMedicalLicense(@RequestBody @Valid MedicalLicenseDto dto) {
        merchantAuditManageService.editMedicalLicense(dto);
    }

    @PostMapping("/editMedicalEduLicense")
    @Operation(summary = "编辑执业许可证教育办学")
    public void editMedicalEduLicense(@RequestBody MedicalEduLicenseDto dto) {
        merchantAuditManageService.editMedicalEduLicense(dto);
    }

    @PostMapping("/editMedicalEduIcpLicense")
    @Operation(summary = "编辑执业许可证教育机构")
    public void editMedicalEduIcpLicense(@RequestBody MedicalEduIcpLicenseDto dto) {
        merchantAuditManageService.editMedicalEduIcpLicense(dto);
    }

    @PostMapping("/editMerVenueInfo")
    @Operation(summary = "编辑产权/租赁信息")
    public void editMerVenueInfo(@RequestBody @Valid MerVenueInfoDto dto) {
        merchantAuditManageService.editMerVenueInfo(dto);
    }

    @PostMapping("/editMerAccountLicense")
    @Operation(summary = "编辑开户信息")
    public void editMerAccountLicense(@RequestBody @Valid MerAccountLicenseDto dto) {
        merchantAuditManageService.editMerAccountLicense(dto);
    }

    @PostMapping("/editMerBusinessInfo")
    @Operation(summary = "编辑商户经营信息")
    public void editMerBusinessInfo(@RequestBody @Valid MerBusinessInfoDto dto) {
        merchantAuditManageService.editMerBusinessInfo(dto);
    }

    @PostMapping("/editMerInstallmentInfo")
    @Operation(summary = "编辑分期信息")
    public void editMerInstallmentInfo(@RequestBody @Valid MerInstallmentInfoDto dto) {
        merchantAuditManageService.editMerInstallmentInfo(dto);
    }

    @PostMapping("/editBackCardListInfo")
    @Operation(summary = "编辑收款户信息")
    public void editBackCardListInfo(@RequestBody @Valid List<MerBackCardDto> backCardDtos) {
        merchantAuditManageService.editBackCardListInfo(backCardDtos);
    }

    @PostMapping("/editMerchantRateInfo")
    @Operation(summary = "编辑费率信息信息")
    public void editMerchantRateInfo(@RequestBody @Valid List<MerchantRateDto> merchantRateDtos) {
        merchantAuditManageService.editMerchantRateInfo(merchantRateDtos);
    }

    @PostMapping("/merchantAudit")
    @Operation(summary = "商户审核")
    public void merchantAudit(@RequestBody MerchantAuditDto dto) {
        merchantAuditManageService.merchantAudit(dto);
    }

    @GetMapping("/getMerchantLevelAndAmout")
    @Operation(summary = "获取商户评级和额度")
    public JSONObject getMerchantLevelAndAmount(@RequestParam(value = "merId") String merId) {
        return merchantAuditManageService.getMerchantLevelAndAmount(merId);
    }


}
